#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include <listitembox.h>
#include <QMediaPlaylist>
#include <QMediaPlayer>
#include "musiclist.h"
enum PageType
{
    LIKE_PAGE,
    LOCAL_PAGE,
    HISTORY_PAGE
};

namespace Ui {
class CommonPage;
}

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();
    void setCommonPageUi(const QString& title,const QString& image);
    void setMusicListType(PageType pageType);//设置音乐列表所在的页面
    void addMusicToMusicPage(MusicList& musicList);//添加音乐到列表
    void addMusicToPlayList(MusicList&musiclist);
    void reFresh(MusicList &musicList);//刷新页面
    void addMusicToPlayer(MusicList& musicList,QMediaPlaylist* playList);
    void addMusicToPlaylist(MusicList& musiclist,QMediaPlaylist* playlist);
    const QString getMusicIdByIndex(int index)const;
    void setMusicImage(QPixmap pixmap);
signals:
    void updateLikeMusic(bool isLike,QString musicId);//我们需要得知哪首歌被收藏了，然后将喜欢的歌刷新的我喜欢页面，发射信号让widget捕捉
    void playAll(PageType);
    void playMusicByIndex(CommonPage* page,int index);
private:
    Ui::CommonPage *ui;
    QVector<QString> musicOfPage;
    PageType pageType;
};

#endif // COMMONPAGE_H
